package ad_exercise_3.controller;

import java.util.Iterator;

import ad_exercise_3.model.Card;
import ad_exercise_3.model.Card.CardColour;
import ad_exercise_3.model.Card.CardType;
import ad_exercise_3.model.CustomStack;

/**
 * This class initializes a new game of UNO
 * 
 * @author Karen Berntsen (s0815799)
 * @author Erik Stens (s0615374)
 */
public class AD_exercise_3 {
	
	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String[] args) {
		new AD_exercise_3();
	}
	
	/**
	 * Main class, initiates the game
	 */
	public AD_exercise_3() {
		new Game();
		// testCustomStackClass();
	}
	
	@SuppressWarnings("unused")
	private void testGameHelper() {
		String input = GameHelper.getUserInput("Input", "option", 5, CardColour.BLUE);
		System.out.println("De input was: " + input);
	}
	
	@SuppressWarnings("unused")
	private void testCustomStackClass() {
		CustomStack<Card> stack1 = new CustomStack<Card>(), stack2 = new CustomStack<Card>(), stack3 = new CustomStack<Card>();
		for (int value = 1; value < 10; value++) {
			Card card = new Card(CardColour.YELLOW, value);
			stack1.addSomewhere(card);
			stack2.addToFront(card);
			stack3.addToBack(card);
		}
		
		stack1.addSomewhere(new Card(CardColour.YELLOW, CardType.TAKE_2));
		stack2.addToFront(new Card(CardColour.YELLOW, CardType.TAKE_2));
		stack3.addToBack(new Card(CardColour.YELLOW, CardType.TAKE_2));
		
		stack1.addSomewhere(new Card(CardColour.YELLOW, CardType.INVERT_DIRECTION));
		stack2.addToFront(new Card(CardColour.YELLOW, CardType.INVERT_DIRECTION));
		stack3.addToBack(new Card(CardColour.YELLOW, CardType.INVERT_DIRECTION));
		
		stack1.addSomewhere(new Card(CardColour.YELLOW, CardType.SKIP_TURN));
		stack2.addToFront(new Card(CardColour.YELLOW, CardType.SKIP_TURN));
		stack3.addToBack(new Card(CardColour.YELLOW, CardType.SKIP_TURN));
		
		Card card1 = new Card(CardType.CHOICE);
		Card card2 = new Card(CardType.CHOICE_TAKE_4);
		stack1.addSomewhere(card1);
		stack2.addToFront(card1);
		stack3.addToBack(card1);
		stack1.addSomewhere(card2);
		stack2.addToFront(card2);
		stack3.addToBack(card2);
		
		System.out.println("The random stack contains:    " + stack1);
		System.out.println("The reverse stack contains:   " + stack2);
		System.out.println("The neat stack contains:      " + stack3);
		
		System.out.print("The neat stack with iterator: ");
		for (Card card : stack3) {
			System.out.print(card + "; ");
		}
		System.out.println();
		
		Iterator<Card> iter = stack3.iterator();
		System.out.print("Removing: ");
		for (int i = 0; iter.hasNext(); i++) {
			Card card = iter.next();
			if (i % 2 == 1) {
				iter.remove();
				System.out.print(card + ", ");
			}
		}
		System.out.println();
		System.out.println("The neat stack now contains: " + stack3);
		
		for (int index = 0; index < stack3.size(); index++) {
			System.out.println("Card " + index + " is: " + stack3.get(index));
		}
		
		stack3.remove(3);
		System.out.println("The neat stack now contains: " + stack3);
		
		stack3.add(3, new Card(CardColour.BLUE, 7));
		System.out.println("The neat stack now contains: " + stack3);
		
		System.out.println("The first card is: " + stack3.getFirst());
		System.out.println("The last card is: " + stack3.getLast());
	}
}